package person.zt;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import person.zt.config.AuthorSettings;
import person.zt.spring_boot_starter_hello.HelloService;

@RestController
@SpringBootApplication
public class ZtestSpringbootApplication {

	//1、基础

	//2、从properties文件中加载内容
	@Value("${book.author}")
	private String bookAuthor;

	@Value("${book.name}")
	private String bookName;

	@RequestMapping("/2")
	String index(){
		//return "Hello Spring Boot";
		return "book name is :《" + bookName + "》 and book author is : " + bookAuthor;
	}

	//3、把properties文件映射成Bean
	@Autowired
	private AuthorSettings authorSettings;

	@RequestMapping("/3")
	public String index2(){
		return "author name is " + authorSettings.getName() + " and author age is " + authorSettings.getAge();
	}

	//4、spring.profiles.active=dev


	//5、AutoConfig
	@Autowired
	HelloService helloService;

	@RequestMapping("/5")
	public String index3(){
		return helloService.sayHello();
	}


	public static void main(String[] args) {
		SpringApplication.run(ZtestSpringbootApplication.class, args);
	}
}
